SetAxisGearInPos
从同步点开始命令从轴和主轴位置之间的齿轮比率。
注意:使用 SetGearInPos() 前主轴必须在恒定速度的移动状态。
运作方式:
首先,从轴以 MoveAxisContinuousAbsolute 移动以正确的时间及速度到达 SlaveSyncPosition,Velocity, Acceleration 与 Deceleration 输入即为此 MoveAxisContinuousAbsolute 移动所设,移动中的 StartSync 输出为 TRUE,一旦此运动完成,InSync 输出即为 TRUE。
GearInPos 设定档:
- 若 MasterStartDistance 非零,主轴位置一到达 MasterSyncPosition +- MasterStartDistance 时从轴即开始移动,Velocity 被视为可能无法达到的最大速度,因此除非速度太低,否则基本上将其省略,接著因为无相容的设定档将触发错误。
- 若 MasterStartDistance 为零而 Velocity 非零,将根据提供的最大速度计算可能的最短曲线。
- 若 MasterStartDistance 与 Velocity 皆为零,KINGSTAR 将生成可能的最顺曲线。
语法
KsCommandStatus SetAxisGearInPos(
int Master,
int Slave,
BOOL Permanent,
double Ratio,
McSource MasterValueSource,
double MasterSyncPosition,
double SlaveSyncPosition,
McSyncMode SyncMode,
double MasterStartDistance,
double Velocity,
double Acceleration,
double Deceleration,
double Jerk,
McBufferMode BufferMode
);
参数
Master [in]:主轴索引。索引以零为起点;别名将影响此参数。
Slave [in]:从轴索引。索引以零为起点;别名将影响此参数。从轴之最大数量为 32 轴。
Permanent [in]:决定马达停用后是否保留齿轮状态。
TRUE:马达停用但保留齿轮状态,例如当主轴启用时从轴也会跟著启用,而当主轴发生错误从轴也会发生错误。
FALSE:马达停用后不会保留齿轮状态。
Ratio [in]:齿轮比例。例如若比例为 3:2,从属装置移动三个单位而主装置移动两个单位。
MasterValueSource [in]:定义同步的来源。请见 McSource 类型。
- mcSetValue – 同步主轴设定值,建议使用此设定。
- mcActualValue-同步主轴实际值,此设定可能不稳定。
- mcSecondEncoderValue – 轴的第二编码器实际值。
注意:尚未支援 mcSecondEncoderValue。
MasterSyncPosition [in]:从轴与主轴同步时主轴的位置。
SlaveSyncPosition [in]:从轴与主轴同步时从轴的位置。
SyncMode [in]:决定同步的方式。请见 McSyncMode 类型。
MasterStartDistance [in]:主轴移动至与从轴同步的距离(当从轴开始进入同步时)。
Velocity [in]:同步阶段的最大速度。
Acceleration [in]:同步阶段的最大加速度。
Deceleration [in]:同步阶段的最大减速度。
Jerk [in]:同步阶段的最大加加速度。
BufferMode [in]:定义如何融合两功能的速度,请见 McBufferMode 类型。
回传值
返回 KsCommandStatus 结构。
备注
- 若使用 MasterStartDistance,则任何先前的运动都会继续,直到主轴以正确的方向穿过 MasterSyncPosition 或 MasterStartDistance(根据 MasterStartDistance 的指示);若在同步发生之前对从轴执行停止命令,其将取消同步且函式将发送 CommandAborted。
- 若未指定 MasterStartDistance,则系统可根据其他相关输入计算同步设定点。
- 在 SyncMode 中,
mcCatchUp
与mcSlowDown
间的不同为同步需要的能源,比起mcCatchUp
,mcSlowDown
需要较低的能源。 - 欲分离从轴,请使用 ReleaseAxis。
- 当模数轴启用时,只有主轴可配置为模数轴,且 MasterSyncPosition 将被转换为模数值,而 MasterStartDistance 不会被转换。例如,若模数值为 360,当主轴的目前位置为 0,速度设定为 180/s,且 MasterSyncPosition 设定为 -20,则主轴将使用 340 作为同步位置。
范例
KsCommandStatus AssignGearSlave(INT Master, INT Slave, DOUBLE MasterPosition, DOUBLE SlavePosition) {
KsCommandStatus gear = WaitForCommand(10, FALSE, SetAxisGearInPos(Master, Slave,
False, //Parameter.Permanent
1, //Gear ratio
mcSetValue, /*Master Value Source. Value of the master position used.
Cam be the target position (commanded value and set value are identical)
or the actual position.*/
MasterPosition, //The master's position where the slave is in sync with the master.
SlavePosition, //The slave's position where the slave is in sync with the master.
mcCatchUp, /*Defines the way to synchronize
(such as "mcShortest," "mcCatchUp," "mcSlowDown"). Vendor-specific.*/
0, //This will be calculated automatically if not provided.
3600,
36000,
36000,
3600000,
mcAborting)
);
return gear;
}
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
标头档 | ksmotion.h | ksmotion.h |
程式库 | KsApi_Rtss.lib | KsApi.lib |
参见